const common = require('./webpack.common')
const {
	merge
} = require('webpack-merge')
const {
	CleanWebpackPlugin
} = require('clean-webpack-plugin') // 打包之前清除 dist 目录
const CopyWebpackPlugin = require('copy-webpack-plugin') // 拷贝静态文件至输出目录
const path = require('path')

module.exports = merge(common, {
	mode: 'production',
	output: {
		filename: 'js/bundle-[name].[hash:8].js'
	},
	plugins: [
		new CleanWebpackPlugin(),
		new CopyWebpackPlugin({
			patterns: [{
				from: path.resolve(__dirname, './public'),to:path.resolve(__dirname, './dist/public')
			}]
		})
	]
})
